﻿@model IEnumerable<PInitiatives.Models.Category>

@{
    ViewBag.Title = "Kategorie";
}

@*@{

    var grid = new WebGrid(source: Model, defaultSort: "Name", rowsPerPage: 3, canPage: true, canSort: true);
    
}

@grid.GetHtml(columns: grid.Columns
                       (
                       grid.Column("Name","Nazwa"),
                       grid.Column(format: (item) => Html.ActionLink("Edit", "Details", new { id = item.id }))
                       )
)*@

<h2>Kategorie</h2>

<table>
    <tr>
        <th>
            Nazwa
        </th>
        <th>
            Kategoria nadrzędna
        </th>
@*        <th>
            Left
        </th>
        <th>
            Right
        </th>
        <th>
            CountInitaitvesInBranch
        </th>*@
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.ParentCategory.Name)
        </td>
@*        <td>
            @Html.DisplayFor(modelItem => item.Left)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Right)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CountInitaitvesInBranch)
        </td>*@
        @if (item.Parent != null)
        {
            <td>
                @Html.ActionLink("Edytuj", "Edit", new { id = item.ID }) |
@*                @Html.ActionLink("Details", "Details", new { id = item.ID }) |*@
                @Html.ActionLink("Usuń", "Delete", new { id = item.ID })
            </td>
        }
    </tr>
}

</table>
<p>
    @Html.ActionLink("Dodaj", "Create")
</p>
